import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: 'Dashboard', icon: 'dashboard' }
    }]
  },
  {
    path: '/yzy',
    component: Layout,
    redirect: '/yzy/greenhouselist',
    name: 'greenhouselist',
    meta: { title: '杨正宇', icon: 'example' },
    children: [
      {
        path: 'applicationlist',
        name: 'ApplicationList',
        component: () => import('@/views/Application/List'),
        meta: { title: '应用列表', icon: 'tree' }
      },
      {
      hidden:true,
        path: 'applicationform',
        name: 'ApplicationForm',
        component: () => import('@/views/Application/Form'),
        meta: { title: '应用表单', icon: 'tree' }
      },
      {
        path: 'greenhouselist',
        name: 'GreenhouseList',
        component: () => import('@/views/Greenhouse/List'),
        meta: { title: '大棚列表', icon: 'tree' }
      },
      {
        hidden:true,
        path: 'greenhouseform',
        name: 'GreenhouseList_Form',
        component: () => import('@/views/Greenhouse/Form'),
        meta: { title: '大棚表单', icon: 'tree' }
      },
      {
        path: 'greenhousemessagelist',
        name: 'GreenhouseMessage',
        component: () => import('@/views/GreenhouseMessage/list'),
        meta: { title: '温室大棚信息', icon: 'tree' }
      },
      {
        hidden:true,
        path: 'greenhousemessageform',
        name: 'greenhousemessageForm',
        component: () => import('@/views/GreenhouseMessage/Form'),
        meta: { title: '新增温室大棚信息', icon: 'tree' }
      },
      {
        path: 'baseconfiglist',
        name: 'BaseConfigList',
        component: () => import('@/views/BaseConfig/list'),
        meta: { title: '基本配置', icon: 'tree' }
      },
      {
        hidden:true,
        path: 'baseconfigform',
        name: 'baseconfigForm',
        component: () => import('@/views/BaseConfig/Form'),
        meta: { title: '新增基本配置信息', icon: 'tree' }
      }, 
      {
       
        path: 'AnimalRecognition',
        component: () => import('@/views/AnimalRecongnition/index'),
        meta: { title: '动物识别', icon: 'tree' }

      },
    ]
  },
  {
    path: '/litongjun',
    component: Layout,
    redirect: '/litongjun/articlelist',
    name: 'articlelist',
    meta: { title: '黎统军', icon: 'example' },
    children: [
      {
        path: 'articlelist',
        name: 'ArticleList',
        component: () => import('@/views/Article/list'),
        meta: { title: '文章', icon: 'tree' }
      },
      {
      hidden:true,
        path: 'articleform',
        name: 'articleForm',
        component: () => import('@/views/Article/Form'),
        meta: { title: '新增文章信息', icon: 'tree' }
      },
      {
        path: 'basefilelist',
        name: 'BaseFileList',
        component: () => import('@/views/BaseFile/list'),
        meta: { title: '基本文件', icon: 'tree' }
      },
      {
        hidden:true,
        path: 'basefileform',
        name: 'basefileform',
        component: () => import('@/views/BaseFile/Form'),
        meta: { title: '新增基本文件信息', icon: 'tree' }
      },
      {
        path: 'baseloglist',
        name: 'BaseLogList',
        component: () => import('@/views/BaseLog/list'),
        meta: { title: '基本日志', icon: 'tree' }
      },
      {
        hidden:true,
        path: 'baselogform',
        name: 'baselogform',
        component: () => import('@/views/BaseLog/Form'),
        meta: { title: '新增基本日志信息', icon: 'tree' }
      },
      {       
          path: 'DishesRecognition',
          name: 'DishesRecognition',
          component: () => import('@/views/DishesRecongnition/index'),
          meta: { title: '菜品识别', icon: 'tree' }
        }
    ]
  },
  {
    path: '/huanghaicheng',
    component: Layout,
    redirect: '/huanghaicheng/commentlist',
    name: 'commentlist',
    meta: { title: '黄海成', icon: 'example' },
    children: [
      {
        path: 'commentlist',
        name: 'CommentList',
        component: () => import('@/views/Comment/list'),
        meta: { title: '评论', icon: 'tree' }
      },
      {
      hidden:true,
        path: 'commentform',
        name: 'commentForm',
        component: () => import('@/views/Comment/Form'),
        meta: { title: '新增评论信息', icon: 'tree' }
      },
      {
        path: 'datasetlist',
        name: 'DatasetList',
        component: () => import('@/views/Dataset/list'),
        meta: { title: '数据集', icon: 'tree' }
      },
      {
        hidden:true,
        path: 'datasetform',
        name: 'DatasetForm',
        component: () => import('@/views/Dataset/Form'),
        meta: { title: '新增数据集信息', icon: 'tree' }
      },
      {
        path: 'datasetfilelist',
        name: 'DatasetFileList',
        component: () => import('@/views/DatasetFile/list'),
        meta: { title: '数据集文件', icon: 'tree' }
      },
      {
        hidden:true,
        path: 'datasetfileform',
        name: 'DatasetFileForm',
        component: () => import('@/views/DatasetFile/Form'),
        meta: { title: '新增数据集信息', icon: 'tree' }
      },
      {
        path: 'fruitsAndvegetables_recognition',
        name: 'fruitsAndvegetablesRecognition',
        component: () => import('@/views/FruitsAndVegetablesRecogntion/Index'),
        meta: { title: '果蔬识别', icon: 'tree' }
      } 
    ]
  },
  {
    path: '/lilu',
    component: Layout,
    redirect: '/lilu/interfacelist',
    name: 'interface',
    meta: { title: '李露', icon: 'example' },
    children: [
      {
        path: 'interfacelist',
        component: () => import('@/views/Interface/list'),
        meta: { title: '接口列表', icon: 'tree' }
      },
      {
        hidden:true,
        path: 'interfaceform',
        component: () => import('@/views/Interface/Form'),
        meta: { title: '新增接口信息', icon: 'tree' }

      },
      {
        path: 'modulelist',
        component: () => import('@/views/Module/list'),
        meta: { title: '模块列表', icon: 'tree' }
      },
      {
        hidden:true,
        path: 'moduleform',
        name: 'ModuleForm',
        component: () => import('@/views/Module/Form'),
        meta: { title: '新增模型信息', icon: 'tree' }
      },
      {
        path: 'roleprivilege',
        name: 'RolePrivilegeList',
        component: () => import('@/views/RolePrivilege/list'),
        meta: { title: '角色权限', icon: 'tree' }
      },
      {
        hidden:true,
        path: 'roleprivilegeform',
        name: 'RolePrivilegeForm',
        component: () => import('@/views/RolePrivilege/Form'),
        meta: { title: '新增角色权限信息', icon: 'tree' }

      },
      {
        path: 'roleuserlist',
        name: 'RoleUserList',
        component: () => import('@/views/RoleUser/list'),
        meta: { title: '角色用户', icon: 'tree' }
      },
      {
        hidden:true,
        path: 'roleuserform',
        name: 'RoleUserForm',
        component: () => import('@/views/RoleUser/Form'),
        meta: { title: '新增模块信息', icon: 'tree' }

      },
      {
        path: 'carDetectRecognition',
        name: 'carDetectRecognition',
        component: () => import('@/views/CarDetectRecognition/index'),
        meta: { title: '车辆检验', icon: 'tree' }
      }     
    ]
  },
  {
    path: '/chenmeifang',
    component: Layout,
    redirect: '/chenmeifang/baseprivilegelist',
    name: 'baseprivilege',
    meta: { title: '陈美芳', icon: 'example' },
    children: [
      {
        path: 'baseprivilegelist',
        name: 'BasePrivilegeList',
        component: () => import('@/views/BasePrivilege/list'),
        meta: { title: '基本权限', icon: 'tree' }
      },
      {
        hidden: true,
        path: 'baseprivilegeform',
        name: 'BasePrivilegeList_form',
        component: () => import('@/views/BasePrivilege/Form'),
        meta: { title: '添加权限' }
      },
      {
        path: 'baserolelist',
        name: 'BaseRoleList',
        component: () => import('@/views/BaseRole/list'),
        meta: { title: '基本角色', icon: 'tree' }
      },
      {
        hidden: true,
        path: 'baseroleform',
        name: 'BaseRoleList_form',
        component: () => import('@/views/BaseRole/Form'),
        meta: { title: '添加角色' }
      },
      {
        path: 'baseuserlist',
        name: 'BaseUserList',
        component: () => import('@/views/BaseUser/list'),
        meta: { title: '基本用户', icon: 'tree' }
      },
      {
        hidden: true,
        path: 'baseuserform',
        name: 'BaseUserList_form',
        component: () => import('@/views/BaseUser/Form'),
        meta: { title: '添加用户' }
      },
      {
        path: 'callloglist',
        name: 'CallLogList',
        component: () => import('@/views/CallLog/list'),
        meta: { title: '访问日志', icon: 'tree' }
      },
      {
        hidden: true,
        path: 'calllogform',
        name: 'CallLogList_form',
        component: () => import('@/views/CallLog/Form'),
        meta: { title: '添加访问日志' }
      },
      {
        path: 'categorylist',
        name: 'CategoryList',
        component: () => import('@/views/Category/list'),
        meta: { title: '技术板块', icon: 'tree' }
      },
      {
        hidden: true,
        path: 'categoryform',
        name: 'Category_form',
        component: () => import('@/views/Category/Form'),
        meta: { title: '添加' }
      },
      {
        path: 'Ingredients_recognition',
        name: 'ingredients_recognition',
        component: () => import('@/views/IngredientsRecognition/index'),
        meta: { title: '食材识别', icon: 'tree' }
      }

    ]
  },
  
  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
